<?php

namespace iBrand\Component\Goods\Models;

use Illuminate\Database\Eloquent\Model;
use Illuminate\Database\Eloquent\SoftDeletes;

class GoodsPhoto extends Model
{
	use SoftDeletes;

	protected $guarded = ['id'];

	public function __construct(array $attributes = [])
	{
		parent::__construct($attributes);

		$prefix = config('ibrand.app.database.prefix', 'ibrand_');

		$this->setTable($prefix . 'base_goods_photo');
	}

	public function goods()
	{
		return $this->belongsTo(Goods::class, 'goods_id');
	}

	public function getCheckedStatusAttribute()
	{
		if ($this->attributes['is_default'] == 1) {
			return 'checked';
		}

		return '';
	}
}